Function Reference

_AD_RecursiveGetMemberOf

Takes a group, user or computer and recursively returns a list of groups the object is a member of.

#Include <AD.au3>
_AD_RecursiveGetMemberOf($sObject[, $iDepth = 10[, $bListInherited = True[, $bFQDN = True]]])

 

Parameters

$sObject User, group or computer for which the group membership is to be returned. Can be specified as Fully Qualified Domain Name (FQDN) or sAMAccountName
$iDepth Optional: Maximum depth of recursion (default = 10)
$bListInherited Optional: Defines if the function returns the group(s) it was inherited from (default = True)
$bFQDN Optional: Specifies the attribute to be returned. True = distinguishedName (FQDN), False = SamAccountName (default = True)

 

Return Value

Success: Returns an one-based one dimensional array of group names (FQDN or sAMAccountName) the user or group is a member of
Failure: "", sets @error to:
    1 - Specified user, group or computer does not exist

 

Remarks

This function traverses the groups that the object is immediately a member of while also checking its group membership.
For groups that are inherited, the return is the FQDN or sAMAccountname of the group, user or computer, and the FQDN(s) or sAMAccountname(s) of the group(s) it
was inherited from, seperated by '|'(s) if flag $bListInherited is set to True.

If flag $bListInherited is set to False then the group names are sorted and only unique groups are returned.

 

Related

_AD_IsMemberOf, _AD_GetUserGroups, _AD_GetUserPrimaryGroup

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
; *****************************************************************************
; Example 1
; Returns a recursively searched list of groups the currently logged on user
; is a member of.
; For groups that are inherited, the FQDN of the group or user, and the FQDN(s)
; of the group(s) it was inherited from, seperated by '|'
; *****************************************************************************
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

; Returns a recursively searched list of groups the currently logged on user is a member of
Global $aUser = _AD_RecursiveGetMemberOf(@UserName, 10, 1)
If @error > 0 Then
    MsgBox(64, "Active Directory Functions - Example 1", "User '" & @UserName & "' has not been assigned to any group")
Else
    ; For groups that are inherited, the return is the FQDN of the group or user, and the FQDN(s) of the group(s) it
    ; was inherited from, seperated by '|'
    _ArrayDisplay($aUser, "Active Directory Functions - Example 1 - Group names user '" & @UserName & "' is a member of")
EndIf

; Close Connection to the Active Directory
_AD_Close()